# test01_css.py
# 导入包
from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep
# 获取浏览器驱动
driver = webdriver.Firefox()
# 打开测试的页面
url = 'file:///root/NSD2408/html/registerA.html'
driver.get(url)
# 定位元素，进行操作
# 通过CSS定位，提供CSS选择器
# username = driver.find_element(By.CSS_SELECTOR, 'input')
# username = driver.find_element(By.CSS_SELECTOR, '#userA')
# username = driver.find_element(By.CSS_SELECTOR, '[name="userA"]')
# username = driver.find_element(By.CSS_SELECTOR, '#p1>input')
# 以某个属性开始  name^="us"
# 以某个属性结束  name$="rA"
# 含有某个属性值  name*="ser"
# username = driver.find_element(By.CSS_SELECTOR, '[name^="us"]')
# username = driver.find_element(By.CSS_SELECTOR, '[name$="rA"]')
username = driver.find_element(By.CSS_SELECTOR, '[name*="ser"]')
username.send_keys('hello')
# 通过CSS定位，定位密码框，电话，邮箱并输入值
# #passwordA
driver.find_element(By.CSS_SELECTOR, '#passwordA').send_keys('123456')
driver.find_element(By.CSS_SELECTOR, '.telA').send_keys('18812345678')
driver.find_element(By.CSS_SELECTOR, '[placeholder="电子邮箱A"]').send_keys('123@qq.com')
# 停顿3秒，通过css定位第2个链接，并点击
sleep(3)
driver.find_element(By.CSS_SELECTOR, '#AAA').click()


# 关闭浏览器
sleep(3)
driver.quit()